#@cmsLayout()

#define cmsContent()
<div class="cms-breadcrumb">
	<i class="layui-icon layui-icon-flag"></i>
	<span class="layui-breadcrumb">
	  	<a href="">用户管理</a>
	  	<a><cite>分配角色</cite></a>
	</span>
</div>

<div class="body-card layui-card">
	<div>
		<h3>给【#(a.nickName)】分配角色</h3>
	</div>
	<table class="layui-table">
	  	<colgroup>
	    	<col width="80">
	    	<col width="180">
	    	<col>
	  	</colgroup>
	 	<thead>
	    	<tr>
	    		<th>分配</th>
	    		<th>角色名</th>
	      		<th>角色说明</th>
	    	</tr> 
	  	</thead>
	  	<tbody>
	  		#for(x : roleList)
	    	<tr>
	      		<td>
	      			<div class="layui-form">
	      				<input type="checkbox" name="switch" value="#(a.id)-#(x.id)" lay-skin="switch" lay-text="ON|OFF" #(x.mark)>
	      			</div>
	      		</td>
	      		<td>#(x.name)</td>
	      		<td>#(x.remark)</td>
	    	</tr>
	    	#end
	  	</tbody>
	</table>
</div>

#@jsInit()

<script>
form.on('switch', function(data){
	var checked = data.elem.checked; //开关是否开启，true或者false
	var value = data.value; //开关value值，3-1(角色id-权限id)
	value = value + "-" +  checked;
	$.post('/cmsAccount/updAccountRole/'+value, function(data){
		if('fail'==data.state){
			layer.alert(data.msg);
		}
	});
});  
</script>

#end